package com.itheima;

import com.itheima.constant.RedisConst;
import com.itheima.untils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPool;

import java.util.Set;

@Component
public class ClearImg {
    @Autowired
    JedisPool jedisPool;
    public void clear(){
        Set<String> sdiff = jedisPool.getResource().sdiff(RedisConst.SETMEAL_PIC_RESOURCES, RedisConst.SETMEAL_PIC_DB_RESOURCES);
        for (String s : sdiff) {
            QiniuUtils.deleteFileFromQiniu(s);
            jedisPool.getResource().srem(RedisConst.SETMEAL_PIC_RESOURCES,s);
        }

    }

}
